<?php

// echo json_encode($_POST);
$link = mysqli_connect("localhost","root","123456","transaction");
// $link = mysqli_connect("sql108.xiaopangkj.space","xiaop_31205296","chen123.","xiaop_31205296_data");
// 插入
$sql = "INSERT INTO user (user_id,password,user_name,grade,user_email) VALUES('{$_POST['user_id']}','{$_POST['password']}','{$_POST['user_name']}',3,'{$_POST['user_email']}')";
// print_r($sql);
//验证数据库是否存在该用户名
$ver= "SELECT * FROM user WHERE user_id='{$_POST['user_id']}'";
$res = mysqli_query($link,$ver);
$one = mysqli_fetch_assoc($res);
if($one['user_id']==$_POST['user_id']){
	$arr["info"] = "用户名已存在";
	$arr["status"] = 0;
	
}else{
	
	mysqli_query($link,$sql);
	$arr["info"] = "注册成功";
	$arr["status"] = 1;
}
echo json_encode($arr);
?>